﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.RepositoryFramework;

namespace Ue.Qcdz.Domain.SinglePages
{
    public class SinglePageService
    {
        private static ISinglePageRepository repository;

        static SinglePageService()
        {
            SinglePageService.repository = RepositoryFactory.GetRepository<ISinglePageRepository, SinglePage>();
        }
        public static SinglePage GetSinglePage(object singlePageKey)
        {
            return SinglePageService.repository.FindBy(singlePageKey);
        }

        public static IList<SinglePage> GetSinglePage()
        {
            return SinglePageService.repository.FindAll();
        }
        public static IDataResult<SinglePage> GetSinglePage(ISinglePageDataQuery dataQuery)
        {
            return SinglePageService.repository.FindBy(dataQuery);
        }

        public static void AddSinglePage(SinglePage singlePage)
        {
            SinglePageService.repository.Add(singlePage);
        }

        public static void RemoveSinglePage(SinglePage singlePage)
        {
            SinglePageService.repository.Remove(singlePage);
        }
        public static void RemoveSinglePage(object singlePageKey)
        {
            SinglePage singlePage = SinglePageService.repository.FindBy(singlePageKey);
            if (singlePage == null)
            {
                throw new ArgumentOutOfRangeException("singlePageKey");
            }

            SinglePageService.repository.Remove(singlePage);
        }

        public static void UpdateSinglePage(SinglePage singlePage)
        {
            SinglePageService.repository[singlePage.Key] = singlePage;
        }
    }
}
